const fs = require('fs');
const path = require('path');
const lessToJS = require('less-vars-to-js');
const withNextAntdLess = require('./next-antd-less.config');

const themeVariables = lessToJS(
  fs.readFileSync(path.resolve(__dirname, './src/antd-custom.less'), 'utf8'),
);

module.exports = {
  ...withNextAntdLess({
    cssModules: true,
    cssLoaderOptions: {
      importLoaders: 1,
      localIdentName: '[local]___[hash:base64:5]',
    },
    lessLoaderOptions: {
      javascriptEnabled: true,
      modifyVars: themeVariables,
    },
  }),
};
